<template>
  <page-header-wrapper>
    <a-card
      title="消息管理"
    >
      <template slot="extra">
        <a-button icon="plus" type="danger" @click="toAdd">发布消息</a-button>
      </template>
      <div class="table-operator">
        <s-table
          bordered
          ref="table"
          size="middle"
          :row-key="(record) => record.id"
          :columns="msgColumns"
          :data="messageData"
        >
          <template slot="action" slot-scope="text,record">
            <a-button size="small" type="primary" @click="toDetail(record.msg_id)">详情</a-button>
          </template>
        </s-table>
      </div>
    </a-card>
  </page-header-wrapper>
</template>

<script>
import { STable } from '@/components'
import col from '@/columns/message'

export default {
  components: {
    STable
  },
  name: 'AllMessage',
  data () {
    return {
      msgColumns: col.message,
      messageData: {}
    }
  },
  activated () {
    this.$refs.table.refresh(true)
  },
  methods: {
    toDetail (id) {
      this.$router.push({ name: 'MessageDetail', params: { id } })
    },
    toAdd () {
      this.$router.push({ name: 'MessageAdd' })
    }
  }
}
</script>

<style scoped>

</style>
